﻿@foreach (Product p in Model)
{
    <div class="box">
        <ul>
            <li>@p.Name</li>
            <li><img src="/images/products/@p.Image" /></li>
            <li>
                @p.UnitPrice
                <button data-id="@p.Id">Add To Cart</button>
            </li>
        </ul>
    </div>
}

<script>
    $(function () {
        $(".box button").click(function () {
            dataId = $(this).attr("data-id");
            $.ajax({
                url: "/Cart/Add",
                data: { id: dataId },
                success: function (response) {
                    $("#cart-count").html(response.Count);
                    $("#cart-amount").html(response.Amount);
                }
            });
        });
    });
</script>